<?php
// no direct access
defined('_JEXEC') or die('Restricted access');

class sanphamHelper
{
	 function getsanpham($params)
	{				
	
		// echo "<pre>";
			// print_r($params);
		// echo "</pre>";
		// exit;
		
		$nhom		= trim( $params['nhom'] );
		$noibat		=(int)( $params['noibat'] );		
		
		// $where0= " ";
		// $where1= " ";
		$where ='';
		if($nhom)
		{
			$where .= " AND danhmuc=".$nhom ;
		}
		
		if($noibat==1)
		{
			$where .= " AND noibat=1 ";
			$ordering= " ORDER BY ordering DESC ";
		}else{
			$ordering= " ORDER BY id DESC ";
		}
		
		
		$strlimit		= (int) $params['strlimit'];
		$soluong		= (int) $params['soluong'];
		
		$sqlnum="select id from dm_sanpham where publish=1 $where";
		$sql="select * from dm_sanpham where publish=1 $where $ordering LIMIT 0, $soluong";
		$querynum=mysql_query($sqlnum);
		$number= mysql_num_rows($querynum);
		$query=mysql_query($sql);	
		
		$value=array();
		$value['query']=$query;
		$value['number']=$number;
		return  $value;
		
	}

}